package com.kun.portal.webframe.po;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by Administrator on 2018/7/5.
 */
@Entity
@Table(
        name = "fbo_maintenance_plan_setting"
)
@DynamicUpdate
public class MaintenancePlanSettingPo {
    @Id
    @GeneratedValue(
            generator = "id"
    )
    @GenericGenerator(
            name = "id",
            strategy = "uuid"
    )
    @Column(
            name = "id",
            length = 32,
            nullable = false
    )
    private String id;

    @Column(
            name = "unit"
    )
    private String  unit;
    @Column(
            name = "cycle"
    )
    private Integer cycle;
    @Column(
            name = "flight"
    )
    private boolean flight;
    @Column(
            name = "maintenance_content",
            length = 100
    )
    private String maintenanceContent;

    @Column(
            name = "least_plane_date"
    )
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @JsonFormat(pattern="yyyy-MM-dd",timezone="Asia/Shanghai")
    @Temporal(TemporalType.DATE)
    private Date leastPlaneDate;




    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.EAGER)
    @JoinColumn(name = "equipment_id", referencedColumnName = "id",insertable = true,updatable = true)
    @JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class,property="@id")
    private EquipmentPo  equipmentPo;

    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.EAGER)
    @JoinColumn(name = "flight_info_id", referencedColumnName = "flight_info_id",insertable = true,updatable = true)
    @JsonIdentityInfo(generator=ObjectIdGenerators.UUIDGenerator.class,property="@id")
    private FlightInfoPo flightInfoPo;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public boolean isFlight() {
        return flight;
    }

    public void setFlight(boolean flight) {
        this.flight = flight;
    }

    public String getMaintenanceContent() {
        return maintenanceContent;
    }

    public void setMaintenanceContent(String maintenanceContent) {
        this.maintenanceContent = maintenanceContent;
    }

    public Date getLeastPlaneDate() {
        return leastPlaneDate;
    }

    public void setLeastPlaneDate(Date leastPlaneDate) {
        this.leastPlaneDate = leastPlaneDate;
    }

    public EquipmentPo getEquipmentPo() {
        return equipmentPo;
    }

    public void setEquipmentPo(EquipmentPo equipmentPo) {
        this.equipmentPo = equipmentPo;
    }

    public FlightInfoPo getFlightInfoPo() {
        return flightInfoPo;
    }

    public void setFlightInfoPo(FlightInfoPo flightInfoPo) {
        this.flightInfoPo = flightInfoPo;
    }

    public Integer getCycle() {
        return cycle;
    }

    public void setCycle(Integer cycle) {
        this.cycle = cycle;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }
}
